package com.hyyt.shopjsp.settlement.service.imp;

import com.hyyt.shopjsp.settlement.dao.ShopSettlementDetailDao;
import com.hyyt.shopjsp.settlement.pojo.ShopSettlementDetail;
import com.hyyt.shopjsp.settlement.service.IShopSettlementDetailService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * SHOP_店铺申请结算明细 Service实现
 *  LC
 */
@Service
public class ShopSettlementDetailService implements IShopSettlementDetailService {

    private static  final Logger logger = Logger.getLogger(IShopSettlementDetailService.class);

    @Resource
    private ShopSettlementDetailDao shopSettlementDetailDao;//SHOP_店铺申请结算明细 Dao接口

    /**
     * 保存SHOP_店铺申请结算明细
     *
     * @param shopSettlementDetail SHOP_店铺申请结算明细
     * @return 保存后的SHOP_店铺申请结算明细
     */
    @Override
    public void saveShopSettlementDetail(ShopSettlementDetail shopSettlementDetail) {
        shopSettlementDetailDao.insert(shopSettlementDetail);
    }

    /**
     * 更新SHOP_店铺申请结算明细
     *
     * @param shopSettlementDetail SHOP_店铺申请结算明细
     * @return 更新后的SHOP_店铺申请结算明细
     */
    @Override
    public void updateShopSettlementDetail(ShopSettlementDetail shopSettlementDetail) {
        shopSettlementDetailDao.update(shopSettlementDetail);
    }

    /**
     * 删除指定ID的SHOP_店铺申请结算明细
     *
     * @param id SHOP_店铺申请结算明细ID
     */
    @Override
    public void deleteShopSettlementDetail(Integer id) {
        shopSettlementDetailDao.delete(id);
    }

    /**
     * 删除指定ID集合的SHOP_店铺申请结算明细
     *
     * @param ids SHOP_店铺申请结算明细ID集合
     */
    @Override
    public void deleteShopSettlementDetail(Collection<Integer> ids) {
        shopSettlementDetailDao.batchDelete(ids);
    }

    /**
     * 根据ID加载一个SHOP_店铺申请结算明细
     *
     * @param id SHOP_店铺申请结算明细ID
     * @return SHOP_店铺申请结算明细
     */
    @Override
    public ShopSettlementDetail loadShopSettlementDetail(Integer id) {
        return shopSettlementDetailDao.load(id);
    }

    /**
     * 查询所有的SHOP_店铺申请结算明细，通常有最多取30000条记录的限制
     *
     * @return 所有的SHOP_店铺申请结算明细，通常有最多取30000条记录的限制
     */
    @Override
    public List<ShopSettlementDetail> queryAllShopSettlementDetail() {
        return shopSettlementDetailDao.queryAll();
    }

    /**
     * 查询SHOP_店铺申请结算明细
     *
     * @param params 查询参数，为key-value形式
     * @return SHOP_店铺申请结算明细集合
     */
    @Override
    public List<ShopSettlementDetail> queryShopSettlementDetail(Map<String, Object> params) {
        return shopSettlementDetailDao.query(params);
    }

    /**
     * 查询SHOP_店铺申请结算明细
     *
     * @param params   查询参数，没有则传null,分页参数key为“sortColumns”
     * @param startRow 起始行数（不含起始行的数据）
     * @param rowSize  要查询记录数
     * @return SHOP_店铺申请结算明细集合
     */
    @Override
    public List<ShopSettlementDetail> queryShopSettlementDetail(Map<String, Object> params, int startRow, int rowSize) {
        return shopSettlementDetailDao.query(params, startRow, rowSize);
    }

    /**
     * 统计SHOP_店铺申请结算明细
     *
     * @param params 查询参数，没有则传null,分页参数key为“sortColumns”
     * @return 结果集记录数
     */
    @Override
    public int countShopSettlementDetail(Map<String, Object> params) {
        return shopSettlementDetailDao.count(params);
    }

    /**
     * 更新SHOP_店铺申请结算明细
     *
     * @param params：settlementId、status
     * @return 更新后的SHOP_店铺申请结算明细
     */
    @Override
    public void updateShopSettlementDetailStatus(Map<String, Object> params) {
        shopSettlementDetailDao.update("updateStatus",params);
    }

    /**
     * 更新SHOP_店铺申请结算明细
     *
     * @param params：settlementId、paymentInfo
     * @return 更新后的SHOP_店铺申请结算明细
     */
    @Override
    public void updateShopSettlementDetailPaymentInfo(Map<String, Object> params) {
        shopSettlementDetailDao.update("updatePaymentInfo",params);
    }

    /**
     * 根据店铺结算ID查询未结算订单列表
     */
    @Override
    public List<Map<String,Object>> querySettlementOrdersBySettlementId(Map<String, Object> params, int startRow, int rowSize){
        return shopSettlementDetailDao.query("querySettlementOrdersBySettlementId",params,startRow,rowSize);
    }

    /**
     * 根据店铺结算ID查询未结算订单数量
     */
    @Override
    public int countSettlementOrdersBySettlementId(Map<String, Object> params){
        return shopSettlementDetailDao.count("countSettlementOrdersBySettlementId",params);
    }

}
